package com.ruoyi.supplier.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.supplier.domain.TbBankIncome;
import com.ruoyi.supplier.service.ITbBankIncomeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 进账类别Controller
 * 
 * @author oliver.li
 * @date 2021-08-14
 */
@RestController
@RequestMapping("/supplier/bankIncome")
public class TbBankIncomeController extends BaseController
{
    @Autowired
    private ITbBankIncomeService tbBankIncomeService;

    /**
     * 查询进账类别列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankIncome:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbBankIncome tbBankIncome)
    {
        startPage();
        List<TbBankIncome> list = tbBankIncomeService.selectTbBankIncomeList(tbBankIncome);
        return getDataTable(list);
    }

    /**
     * 导出进账类别列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankIncome:export')")
    @Log(title = "进账类别", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbBankIncome tbBankIncome)
    {
        List<TbBankIncome> list = tbBankIncomeService.selectTbBankIncomeList(tbBankIncome);
        ExcelUtil<TbBankIncome> util = new ExcelUtil<TbBankIncome>(TbBankIncome.class);
        return util.exportExcel(list, "进账类别数据");
    }

    /**
     * 获取进账类别详细信息
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankIncome:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tbBankIncomeService.selectTbBankIncomeById(id));
    }

    /**
     * 新增进账类别
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankIncome:add')")
    @Log(title = "进账类别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbBankIncome tbBankIncome)
    {
        return toAjax(tbBankIncomeService.insertTbBankIncome(tbBankIncome));
    }

    /**
     * 修改进账类别
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankIncome:edit')")
    @Log(title = "进账类别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbBankIncome tbBankIncome)
    {
        return toAjax(tbBankIncomeService.updateTbBankIncome(tbBankIncome));
    }

    /**
     * 删除进账类别
     */
    @PreAuthorize("@ss.hasPermi('supplier:bankIncome:remove')")
    @Log(title = "进账类别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbBankIncomeService.deleteTbBankIncomeByIds(ids));
    }
}
